public class Solution {
    public int[] smallestK(int[] arr, int k) {
        PriorityQueue<Integer> minHeap = new PriorityQueue<>();
        //取出数组的每个元素放入小根堆中
        for(int i = 0;i < arr.length;i++){
            minHeap.offer(arr[i]);
        }
        //弹出k个元素，存放在数组当中，返回即可
        int[] tmp = new int[k];
        for(int i = 0;i < k;i++){
            tmp[i] = minHeap.poll();
        }
        return tmp;
    }
}
